home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 1.iso
/
toolbox
/
src
/
exampleCode
/
opengl
/
xlib
/
tprim_pup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-11
|
19KB
|
792 lines
/*
* (c) Copyright 1994, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
*
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* clause at DFARS 252.227-7013 and/or in similar or successor
* clauses in the FAR or the DOD or NASA FAR Supplement.
* Unpublished-- rights reserved under the copyright laws of the
* United States. Contractor/manufacturer is Silicon Graphics,
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <GL/glx.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <X11/keysym.h>
#include "pup.h"
static int RGB_attributes[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None,
};
static int CI_attributes[] = {
None,
};
int rgb = 1;
#define PIXEL_CENTER(x) ((long) (x) + 0.5)
#define SETCOLOR(x) (rgb ? glColor3fv(rgbMap[x]) : glIndexf(x))
enum {
BLACK = 0,
RED,
GREEN,
YELLOW,
BLUE,
MAGENTA,
CYAN,
WHITE
};
static float rgbMap[8][3] = {
{0, 0, 0},
{1, 0, 0},
{0, 1, 0},
{1, 1, 0},
{0, 0, 1},
{1, 0, 1},
{0, 1, 1},
{1, 1, 1}
};
#define GAP 10
#define ROWS 3
#define COLS 4
static long W = COLS*100 + (COLS + 1)*GAP;
static long H = ROWS*100 + (ROWS + 1)*GAP;
static long boxW = 101;
static long boxH = 101;
static void Viewport(long row, long column)
{
long x, y;
x = GAP + column * (boxW + GAP);
y = GAP + row * (boxH + GAP);
if (rgb) {
glClearColor(0, 0, 0, 0);
} else {
glClearIndex(0);
}
glEnable(GL_SCISSOR_TEST);
glScissor(x, y, boxW, boxH);
glViewport(x, y, boxW, boxH);
glPushAttrib(GL_COLOR_BUFFER_BIT);
glColorMask(1, 1, 1, 1);
glIndexMask(~0);
glClear(GL_COLOR_BUFFER_BIT);
glPopAttrib();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-boxW/2, boxW/2, -boxH/2, boxH/2, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
}
static void Point(void)
{
long i;
SETCOLOR(WHITE);
glBegin(GL_POINTS);
glVertex2i(0, 0);
for (i = 1; i < 8; i++) {
long j = i * 2;
SETCOLOR(i);
glVertex2i(-j, -j);
glVertex2i(-j, 0);
glVertex2i(-j, j);
glVertex2i(0, j);
glVertex2i(j, j);
glVertex2i(j, 0);
glVertex2i(j, -j);
glVertex2i(0, -j);
}
glEnd();
}
static void Lines(void)
{
long i;
glPushMatrix();
glTranslatef(-12, 0, 0);
for (i = 1; i < 8; i++) {
SETCOLOR(i);
glBegin(GL_LINES);
glVertex2i(-boxW/4, -boxH/4);
glVertex2i(boxW/4, boxH/4);
glEnd();
glTranslatef(4, 0, 0);
}
glPopMatrix();
/*
** Draw a single vertex line to make sure nothing bad happens
*/
glBegin(GL_LINES);
glVertex2i(0, 0);
glEnd();
}
static void LineStrip(void)
{
glBegin(GL_LINE_STRIP);
SETCOLOR(RED);
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
SETCOLOR(GREEN);
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
SETCOLOR(BLUE);
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
SETCOLOR(WHITE);
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
glEnd();
/*
** Draw a single vertex line to make sure nothing bad happens
*/
glBegin(GL_LINE_STRIP);
glVertex2i(0, 0);
glEnd();
}
static void LineLoop(void)
{
glBegin(GL_LINE_LOOP);
SETCOLOR(RED);
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(-boxH/4));
SETCOLOR(GREEN);
glVertex2f(PIXEL_CENTER(-boxW/4), PIXEL_CENTER(boxH/4));
SETCOLOR(BLUE);
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(boxH/4));
SETCOLOR(WHITE);
glVertex2f(PIXEL_CENTER(boxW/4), PIXEL_CENTER(-boxH/4));
glEnd();
/*
** Draw a two vertex line with XOR on to make sure that only the
** endpoints show. Since each line segment is drawn half-open,
** the endpoints will not be drawn twice, thus leaving the XOR of
** white in the color buffer. When using an RGB color buffer, use
** the blend function to approximate the effects of the XOR.
*/
glEnable(GL_LOGIC_OP);
glEnable(GL_BLEND);
glLogicOp(GL_XOR);
glBlendFunc(GL_ONE, GL_ONE);
SETCOLOR(MAGENTA);
/* this line is vertical */
glBegin(GL_LINE_LOOP);
glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(-boxH/8));
glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8));
glEnd();
/* this line is horizontal */
glBegin(GL_LINE_LOOP);
glVertex2f(PIXEL_CENTER(-boxW/8), PIXEL_CENTER(boxH/8+5));
glVertex2f(PIXEL_CENTER(boxW/8), PIXEL_CENTER(boxH/8+5));
glEnd();
glDisable(GL_LOGIC_OP);
glDisable(GL_BLEND);
/*
** Draw a point at the center of the area so that we can count pixels
** if needed.
*/
SETCOLOR(GREEN);
glBegin(GL_POINTS);
glVertex2i(0, 0);
glEnd();
/*
** Draw a single vertex line to make sure nothing bad happens
*/
glBegin(GL_LINE_LOOP);
glVertex2i(0, 0);
glEnd();
}
#define OPENGL_WIDTH 48
#define OPENGL_HEIGHT 13
static GLubyte OpenGL_bits[] = {
0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
0x7f, 0xfb, 0xff, 0xff, 0xff, 0x01,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0x3e, 0x8f, 0xb7, 0xf9, 0xfc, 0x01,
0x63, 0xdb, 0xb0, 0x8d, 0x0d, 0x00,
0x63, 0xdb, 0xb7, 0x8d, 0x0d, 0x00,
0x63, 0xdb, 0xb6, 0x8d, 0x0d, 0x00,
0x63, 0x8f, 0xf3, 0xcc, 0x0d, 0x00,
0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0a,
0x63, 0x00, 0x00, 0x0c, 0x4c, 0x0e,
0x63, 0x00, 0x00, 0x8c, 0xed, 0x0e,
0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00,
};
static void Bitmap(void)
{
static const long xOrigin = 0;
static const long yOrigin = 3;
/*
** Draw some lines showing the left and bottom edges of the bitmap.
** The red line is the vertical left edge of the bitmap. The blue
** line is the horizontal bottom edge of the bitmap. The yellow line
** is the horizontal base line of the bitmap. The green lines mark
** where the rasterpos will translate to. Take into account the x
** origin.
*/
glBegin(GL_LINES);
SETCOLOR(GREEN);
glVertex2i(-boxW/2, 0);
glVertex2i(boxW/2, 0);
glVertex2i(0, -boxH/2);
glVertex2i(0, boxH/2);
SETCOLOR(RED);
glVertex2i(-xOrigin, -yOrigin);
glVertex2i(-xOrigin, -yOrigin+OPENGL_HEIGHT);
SETCOLOR(BLUE);
glVertex2i(-xOrigin, -yOrigin);
glVertex2i(-xOrigin+OPENGL_WIDTH, -yOrigin);
glEnd();
SETCOLOR(GREEN);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_TRUE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glRasterPos2i(0, 0);
glBitmap(OPENGL_WIDTH, OPENGL_HEIGHT, xOrigin, yOrigin, 0.0, 0.0,
OpenGL_bits);
}
static void Triangles(void)
{
glBegin(GL_TRIANGLES);
SETCOLOR(GREEN);
glVertex2i(-boxW/4, -boxH/4);
SETCOLOR(RED);
glVertex2i(-boxW/8, -boxH/16);
SETCOLOR(BLUE);
glVertex2i(boxW/8, -boxH/16);
SETCOLOR(GREEN);
glVertex2i(-boxW/4, boxH/4);
SETCOLOR(RED);
glVertex2i(-boxW/8, boxH/16);
SETCOLOR(BLUE);
glVertex2i(boxW/8, boxH/16);
glEnd();
/*
** Generate a 2 vertex triangle that should draw nothing
*/
glBegin(GL_TRIANGLES);
glVertex2i(0, 0);
glVertex2i(-100, 100);
glEnd();
}
static void TriangleStrip(void)
{
glBegin(GL_TRIANGLE_STRIP);
SETCOLOR(GREEN);
glVertex2i(-boxW/4, -boxH/4);
SETCOLOR(RED);
glVertex2i(-boxW/4, boxH/4);
SETCOLOR(BLUE);
glVertex2i(0, -boxH/4);
SETCOLOR(WHITE);
glVertex2i(0, boxH/4);
SETCOLOR(CYAN);
glVertex2i(boxW/4, -boxH/4);
SETCOLOR(YELLOW);
glVertex2i(boxW/4, boxH/4);
glEnd();
/*
** Generate a 2 vertex triangle strip that should draw nothing
*/
glBegin(GL_TRIANGLE_STRIP);
glVertex2i(0, 0);
glVertex2i(-100, 100);
glEnd();
}
static void TriangleFan(void)
{
long x0, x1, x2, x3;
long y0, y1, y2, y3;
long vx[8][2];
long i;
/*
** Construct an 8 sided convex polygon that is almost an octahedron
*/
y0 = -boxH/4;
y1 = y0 + boxH/2/3;
y2 = y1 + boxH/2/3;
y3 = boxH/4;
x0 = -boxW/4;
x1 = x0 + boxW/2/3;
x2 = x1 + boxW/2/3;
x3 = boxW/4;
vx[0][0] = x0; vx[0][1] = y1;
vx[1][0] = x0; vx[1][1] = y2;
vx[2][0] = x1; vx[2][1] = y3;
vx[3][0] = x2; vx[3][1] = y3;
vx[4][0] = x3; vx[4][1] = y2;
vx[5][0] = x3; vx[5][1] = y1;
vx[6][0] = x2; vx[6][1] = y0;
vx[7][0] = x1; vx[7][1] = y0;
/*
** Draw the polygon, shaded. This will draw the same shape that the
** polygon test draws, except that when flat shaded it should draw
** entirely white. When smooth shaded it will shade differently
** than the polygon test.
*/
glBegin(GL_TRIANGLE_FAN);
SETCOLOR(WHITE);
glVertex2i(0, 0);
for (i = 0; i < 8; i++) {
SETCOLOR(7-i);
glVertex2iv((const GLint *)vx[i]);
}
glEnd();
/*
** Generate a 2 vertex triangle fan that should draw nothing
*/
glBegin(GL_TRIANGLE_FAN);
glVertex2i(0, 0);
glVertex2i(-100, 100);
glEnd();
}
static void Rect(void)
{
SETCOLOR(GREEN);
glRecti(-boxW/4, -boxH/4, boxW/4, boxH/4);
}
static void Polygon(void)
{
long x0, x1, x2, x3;
long y0, y1, y2, y3;
long vx[8][2];
long i;
/*
** Construct an 8 sided convex polygon that is almost an octahedron
*/
y0 = -boxH/4;
y1 = y0 + boxH/2/3;
y2 = y1 + boxH/2/3;
y3 = boxH/4;
x0 = -boxW/4;
x1 = x0 + boxW/2/3;
x2 = x1 + boxW/2/3;
x3 = boxW/4;
vx[0][0] = x0; vx[0][1] = y1;
vx[1][0] = x0; vx[1][1] = y2;
vx[2][0] = x1; vx[2][1] = y3;
vx[3][0] = x2; vx[3][1] = y3;
vx[4][0] = x3; vx[4][1] = y2;
vx[5][0] = x3; vx[5][1] = y1;
vx[6][0] = x2; vx[6][1] = y0;
vx[7][0] = x1; vx[7][1] = y0;
/*
** Draw the polygon, shaded.
*/
glBegin(GL_POLYGON);
for (i = 0; i < 8; i++) {
SETCOLOR(7-i);
glVertex2iv((const GLint *)vx[i]);
}
glEnd();
/*
** Generate a 2 vertex polygon that should draw nothing
*/
glBegin(GL_POLYGON);
glVertex2i(0, 0);
glVertex2i(100, 100);
glEnd();
}
static void Quads(void)
{
glBegin(GL_QUADS);
SETCOLOR(GREEN);
glVertex2i(-boxW/4, -boxH/4);
SETCOLOR(RED);
glVertex2i(-boxW/8, -boxH/16);
SETCOLOR(BLUE);
glVertex2i(boxW/8, -boxH/16);
SETCOLOR(WHITE);
glVertex2i(boxW/4, -boxH/4);
SETCOLOR(GREEN);
glVertex2i(-boxW/4, boxH/4);
SETCOLOR(RED);
glVertex2i(-boxW/8, boxH/16);
SETCOLOR(BLUE);
glVertex2i(boxW/8, boxH/16);
SETCOLOR(WHITE);
glVertex2i(boxW/4, boxH/4);
glEnd();
/*
** Generate a 3 vertex quad that should draw nothing
*/
glBegin(GL_QUADS);
glVertex2i(0, 0);
glVertex2i(100, 100);
glVertex2i(-100, 100);
glEnd();
}
static void QuadStrip(void)
{
glBegin(GL_QUAD_STRIP);
SETCOLOR(GREEN);
glVertex2i(-boxW/4, -boxH/4);
SETCOLOR(RED);
glVertex2i(-boxW/4, boxH/4);
SETCOLOR(BLUE);
glVertex2i(0, -boxH/4);
SETCOLOR(WHITE);
glVertex2i(0, boxH/4);
SETCOLOR(CYAN);
glVertex2i(boxW/4, -boxH/4);
SETCOLOR(YELLOW);
glVertex2i(boxW/4, boxH/4);
glEnd();
/*
** Generate a 3 vertex quad strip that should draw nothing
*/
glBegin(GL_QUAD_STRIP);
glVertex2i(0, 0);
glVertex2i(100, 100);
glVertex2i(-100, 100);
glEnd();
}
static void RotateColorMask(void)
{
static long rotation=0;
rotation = (rotation + 1) & 0x3;
switch (rotation) {
case 0:
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glIndexMask( 0xff );
break;
case 1:
/* mask off red */
glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
glIndexMask( 0xfe );
break;
case 2:
/* mask off green */
glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE);
glIndexMask( 0xfd );
break;
case 3:
/* mask off blue */
glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE);
glIndexMask( 0xfb );
break;
}
}
static void DoTests(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
Viewport(0, 0); Point();
Viewport(0, 1); Lines();
Viewport(0, 2); LineStrip();
Viewport(0, 3); LineLoop();
Viewport(1, 0); Bitmap();
Viewport(1, 1); TriangleFan();
Viewport(1, 2); Triangles();
Viewport(1, 3); TriangleStrip();
Viewport(2, 0); Rect();
Viewport(2, 1); Polygon();
Viewport(2, 2); Quads();
Viewport(2, 3); QuadStrip();
glFlush();
}
static void Usage(void)
{
printf("Usage: tprim [-c]\n");
printf(" -c: Run in color index mode\n");
exit(-1);
}
static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg)
{
if ((e->type == MapNotify) && (e->xmap.window == (Window)arg)) {
return GL_TRUE;
}
return GL_FALSE;
}
int main(int argc, char** argv)
{
XVisualInfo *vi;
Display *dpy;
Colormap cmap;
Window window;
XSetWindowAttributes swa;
GLXContext cx;
XEvent event;
GLboolean needDisplay;
XColor white;
char *geometry = NULL;
XSizeHints sizehints;
int i;
long menu, smenu, pmenu;
rgb = 1;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-geometry")) {
i++;
geometry = argv[i];
} else if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'c':
rgb = GL_FALSE;
break;
default:
Usage();
}
} else {
Usage();
}
}
dpy = XOpenDisplay(0);
if (!dpy) {
fprintf(stderr, "Can't connect to display \"%s\"\n", getenv("DISPLAY"));
return -1;
}
vi = glXChooseVisual(dpy, DefaultScreen(dpy),
rgb ? RGB_attributes : CI_attributes);
if (!vi) {
fprintf(stderr, "No singlebuffered rgba visual on \"%s\"\n",
getenv("DISPLAY"));
return -1;
}
cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual,
AllocNone);
white.red = ~0;
white.green = ~0;
white.blue = ~0;
XAllocColor(dpy, cmap, &white);
sizehints.flags = PPosition | PSize;
sizehints.width = W;
sizehints.height = H;
sizehints.x = 10;
sizehints.y = 10;
if(geometry) {
int flags, x, y, width, height;
flags = XParseGeometry(geometry, &x, &y,
(unsigned int *)&width,
(unsigned int *)&height);
if(WidthValue & flags) {
sizehints.flags |= USSize;
sizehints.width = width;
W = width;
}
if(HeightValue & flags) {
sizehints.flags |= USSize;
sizehints.height = height;
H = height;
}
if(XValue & flags) {
if(XNegative & flags)
x = DisplayWidth(dpy, DefaultScreen(dpy)) + x
- sizehints.width;
sizehints.flags |= USPosition;
sizehints.x = x;
}
if(YValue & flags) {
if(YNegative & flags)
y = DisplayHeight(dpy, DefaultScreen(dpy)) + y
- sizehints.height;
sizehints.flags |= USPosition;
sizehints.y = y;
}
}
swa.border_pixel = 0;
swa.background_pixel = white.pixel;
swa.colormap = cmap;
swa.event_mask = ExposureMask | StructureNotifyMask | KeyPressMask
| KeyReleaseMask | ButtonPressMask;
window = XCreateWindow(dpy, RootWindow(dpy, vi->screen),
sizehints.x, sizehints.y,
sizehints.width, sizehints.height,
0, vi->depth, InputOutput, vi->visual,
CWBackPixel|CWBorderPixel|CWColormap|CWEventMask,
&swa);
XSetStandardProperties(dpy, window, rgb ? "tprim RGB" : "tprim CI", "tprim",
None, argv, argc, &sizehints);
XSetWMColormapWindows(dpy, window, &window, 1);
XMapWindow(dpy, window);
XIfEvent(dpy, &event, WaitForMapNotify, (char*)window);
cx = glXCreateContext(dpy, vi, 0, GL_TRUE);
if (!glXMakeCurrent(dpy, window, cx)) {
fprintf(stderr, "Can't make window current to context\n");
return -1;
}
smenu = defpup(dpy, DefaultScreen(dpy), "GL_FLAT %x1|GL_SMOOTH %x2");
pmenu = defpup(dpy, DefaultScreen(dpy), "GL_FILL %x3|GL_LINE %x4|GL_POINT %x5");
menu = defpup(dpy, DefaultScreen(dpy), "glShadeModel %m|glPolygonMode %m|rotate color mask %x6%l|quit %x7", smenu, pmenu);
needDisplay = GL_TRUE;
for (;;) {
do {
XNextEvent(dpy, &event);
switch (event.type) {
case Expose:
needDisplay = GL_TRUE;
break;
case ConfigureNotify:
W = event.xconfigure.width;
H = event.xconfigure.height;
needDisplay = GL_TRUE;
break;
case KeyPress:
{
char buf[100];
int rv;
KeySym ks;
rv = XLookupString(&event.xkey, buf, sizeof(buf), &ks, 0);
switch (ks) {
case XK_F:
case XK_f:
glShadeModel(GL_FLAT);
needDisplay = GL_TRUE;
break;
case XK_S:
case XK_s:
glShadeModel(GL_SMOOTH);
needDisplay = GL_TRUE;
break;
case XK_P:
case XK_p:
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
needDisplay = GL_TRUE;
break;
case XK_L:
case XK_l:
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
needDisplay = GL_TRUE;
break;
case XK_C:
case XK_c:
RotateColorMask();
needDisplay = GL_TRUE;
break;
case XK_Escape:
return 0;
}
}
break;
case ButtonPress:
switch(dopup(menu)) {
case 1:
glShadeModel(GL_FLAT);
needDisplay = GL_TRUE;
break;
case 2:
glShadeModel(GL_SMOOTH);
needDisplay = GL_TRUE;
break;
case 3:
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
needDisplay = GL_TRUE;
break;
case 4:
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
needDisplay = GL_TRUE;
break;
case 5:
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
needDisplay = GL_TRUE;
break;
case 6:
RotateColorMask();
needDisplay = GL_TRUE;
break;
case 7:
exit(0);
case -1:
break;
}
}
} while (XPending(dpy) != 0);
if (needDisplay) {
needDisplay = GL_FALSE;
DoTests();
}
}
}